import os
from pathlib import Path
from datetime import datetime

def setup_output_directory(output_dir: Path) -> None:
    """
    Create the output directory structure
    """
    # Create main output directory
    output_dir.mkdir(parents=True, exist_ok=True)
    
    # Create subdirectories for different types of output
    (output_dir / 'reports').mkdir(exist_ok=True)
    (output_dir / 'logs').mkdir(exist_ok=True)
    (output_dir / 'statistics').mkdir(exist_ok=True)

def get_timestamp() -> str:
    """
    Get current timestamp in a formatted string
    """
    return datetime.now().strftime("%Y%m%d_%H%M%S")

def is_valid_document(filename: str) -> bool:
    """
    Check if the file is a valid document file
    """
    valid_extensions = ['.doc', '.docx']
    return any(filename.lower().endswith(ext) for ext in valid_extensions)

def extract_student_info(filename: str) -> tuple:
    """
    Extract student ID and name from filename
    Expected format: student_id_name.doc(x)
    """
    try:
        base_name = os.path.splitext(filename)[0]
        student_id, student_name = base_name.split('_', 1)
        return student_id, student_name
    except ValueError:
        raise ValueError(f"Invalid filename format: {filename}. Expected format: student_id_name.doc(x)") 